// pages/game/game.js

//URL
const Game_list_url = 'https://shop1.mollyfantasy.universal-space.cn/p14/app/member/mygame';


Page({

  /**
   * 页面的初始数据
   */
  data:{

    showEmptyView: false,
    showListView: false,

      items:[
          {
            "image":"/images/ic_device1.png",
            "name":"Dazzling basketball",
            "desc":"A fun shooting"
          },
          {
            "image":"/images/ic_device1.png",
            "name":"Dazzling basketball",
            "desc":"A fun shooting"
          },
          {
            "image":"/images/ic_device1.png",
            "name":"Dazzling basketball",
            "desc":"A fun shooting"
          },
      ]



  },


  /**
   * 监听页面加载
   */
  onLoad(query) {
    
    var token = wx.getStorageSync("utoken");


    wx.startPullDownRefresh({
      success: (result)=>{
        console.log("下拉了");
        wx.request(
        {
          url:Game_list_url,
          method:"POST",
          header:{
              "utoken":token
          },
          success:  (data) =>{
            console.log(data);
            if(data.data.data.length == 0){
                this.setData({
                  showEmptyView : true,
                  showListView : false
                })
              
            }else{

              this.setData({
                showEmptyView : true,
                showListView : false
              })
            
            }
            wx.stopPullDownRefresh();
          }
        }
    )
      },
      fail: ()=>{},
      complete: ()=>{}
    });
    
  },

  /**
   * 监听页面初次渲染完成
   */
  onReady() {

  }


})

